Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-retry

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-retry

Axios plugin that intercepts failed requests and retries them whenever posible.

  • 3.9.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is axios-retry?

The axios-retry npm package is a utility that allows you to automatically retry failed HTTP requests made using the Axios library. It is particularly useful for dealing with transient errors or unstable network conditions. It provides several options to customize the retry behavior, such as the number of retries, retry delay, and the conditions for which requests should be retried.

What are axios-retry's main functionalities?

Automatic Retries

Automatically retries a failed HTTP request up to a specified number of times.

const axios = require('axios');
const axiosRetry = require('axios-retry');

axiosRetry(axios, { retries: 3 });

axios.get('https://example.com').catch(error => {
  console.error('Request failed:', error);
});

Custom Retry Conditions

Allows you to specify custom conditions for when a request should be retried, such as on certain HTTP status codes or network errors.

const axios = require('axios');
const axiosRetry = require('axios-retry');

axiosRetry(axios, {
  retryCondition: (error) => {
    // Retry on any network error, or 5xx status codes
    return axiosRetry.isNetworkOrIdempotentRequestError(error) || error.response.status === 503;
  }
});

Exponential Backoff

Implements an exponential backoff strategy for the delay between retries, which can help to avoid overwhelming the server.

const axios = require('axios');
const axiosRetry = require('axios-retry');

axiosRetry(axios, {
  retries: 5,
  retryDelay: (retryCount) => {
    return axiosRetry.exponentialDelay(retryCount);
  }
});

Retry on Idempotent Requests Only

Configures the retry mechanism to only retry idempotent requests, which are requests that can be repeated without causing additional side effects.

const axios = require('axios');
const axiosRetry = require('axios-retry');

axiosRetry(axios, {
  retries: 3,
  shouldResetTimeout: true,
  retryCondition: axiosRetry.isIdempotentRequestError
});

Other packages similar to axios-retry

FAQs

Package last updated on 16 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc